package com.holly.unit.kafka.model;

import lombok.Data;
import lombok.ToString;

/**
 * 
 * kafka 消息实体
 * key   key为null，则使用轮询算法均衡地分配分区,
 *       key不为null，则根据 key.hashcode % kafka节点个数
 * value 发送的数据
 * @author pengpeng
 *
 */
@Data
@ToString
public class Kmessage {
	private Object key;//key用于分配分区，非必填
	private Object val;//消息主体
	private String topic;//订阅主题
	private Long offset;//这条消息处于Kafka分区中的哪个位置
	private Integer partition;//分区，非必填
	
	public Kmessage(Object key, Object val, String topic, Integer partition) {
		super();
		this.key = key;
		this.val = val;
		this.topic = topic;
		this.partition = partition;
	}
	public Kmessage(Object key, Object val, String topic) {
		super();
		this.key = key;
		this.val = val;
		this.topic = topic;
	}
	public Kmessage(Object val, String topic) {
		super();
		this.val = val;
		this.topic = topic;
	}
	
	public Kmessage() {
		super();
	}

}